package com.zgg.enums;

/**
 * Created by Administrator on 2017/9/18 0018.
 */
public enum AliOssImageEnum {

    //操作类型
    //缩放
    ALI_HANDLE_RESIZE(0, "resize"),
    //裁剪
    ALI_HANDLE_CROP(1, "crop"),
    //旋转
    ALI_HANDLE_ROTATE(2, "rotate"),
    //模糊
    ALI_HANDLE_BLUR(3, "blur"),
    //亮度
    ALI_HANDLE_BRIGHT(4, "bright"),
    //对比度
    ALI_HANDLE_CONTRAST(5, "contrast"),
    //锐化
    ALI_HANDLE_SHARPEN(6, "sharpen"),
    //水印
    ALI_HANDLE_WATERMARK(7, "watermark"),
    //格式转换
    ALI_HANDLE_FORMAT(8, "format"),
    //图片信息
    ALI_HANDLE_INFO(9, "info"),
    //图片样式
    ALI_HANDLE_SYTLE(100, "style"),

    //缩放类型
    //等比缩放，限制在设定在指定w与h的矩形内的最大图片。
    ALI_HANDLE_RESIZE_LFIT(10, "_lfit"),
    //等比缩放，延伸出指定w与h的矩形框外的最小图片。
    ALI_HANDLE_RESIZE_MFIT(11, "_mfit"),
    //固定宽高，将延伸出指定w与h的矩形框外的最小图片进行居中裁剪。
    ALI_HANDLE_RESIZE_FILL(12, "_fill"),
    //固定宽高，缩略填充。
    ALI_HANDLE_RESIZE_PAD(13, "_pad"),
    //固定宽高，强制缩略
    ALI_HANDLE_RESIZE_FIXED(14, "_fixed"),

    //水印位置
    //上排从左到右
    ALI_HANDLE_POSITION_NW(15, "nw"),
    ALI_HANDLE_POSITION_NORTH(16, "north"),
    ALI_HANDLE_POSITION_NE(17, "ne"),
    //中排从左到右
    ALI_HANDLE_POSITION_WEST(18, "west"),
    ALI_HANDLE_POSITION_CENTER(19, "center"),
    ALI_HANDLE_POSITION_EAST(20, "east"),
    //下排从左到右
    ALI_HANDLE_POSITION_SW(21, "sw"),
    ALI_HANDLE_POSITION_SOUTH(22, "south"),
    ALI_HANDLE_POSITION_SE(23, "se"),

    //水印文字类型
    ALI_HANDLE_TEXT_WQY_ZENHEI(24, "wqy-zenhei"),
    ALI_HANDLE_TEXT_WQY_MICROHEI(25, "wqy-microhei"),
    ALI_HANDLE_TEXT_FZ_SHUSONG(26, "fangzhengshusong"),
    ALI_HANDLE_TEXT_FZ_KAITI(27, "fangzhengkaiti"),
    ALI_HANDLE_TEXT_FZ_HEITI(28, "fangzhengheiti"),
    ALI_HANDLE_TEXT_FZ_FANGSONG(29, "fangzhengfangsong"),
    ALI_HANDLE_TEXT_DROIDSANSFALLBACK(30, "droidsansfallback"),


    //文件格式
    ALI_FORMAT_JPG(40, "jpg"),
    ALI_FORMAT_PNG(41, "png"),
    ALI_FORMAT_WEBP(42, "webp"),
    ALI_FORMAT_BMP(43, "bmp"),
    ALI_FORMAT_GIF(44, "gif");


    private int id;
    private String value;

    AliOssImageEnum(int id, String value) {
        this.id = id;
        this.value = value;
    }


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    /**
     * 操作类型
     *
     * @param handleType
     * @return
     */
    public static String getAliOssImageHandleType(int handleType) {
        switch (handleType) {
            case 0:
                return ALI_HANDLE_RESIZE.getValue();
            case 1:
                return ALI_HANDLE_CROP.getValue();
            case 2:
                return ALI_HANDLE_ROTATE.getValue();
            case 3:
                return ALI_HANDLE_BLUR.getValue();
            case 4:
                return ALI_HANDLE_BRIGHT.getValue();
            case 5:
                return ALI_HANDLE_CONTRAST.getValue();
            case 6:
                return ALI_HANDLE_SHARPEN.getValue();
            case 7:
                return ALI_HANDLE_WATERMARK.getValue();
            case 8:
                return ALI_HANDLE_FORMAT.getValue();
            case 9:
                return ALI_HANDLE_INFO.getValue();
            default:
                return "";
        }
    }

    /**
     * 压缩方式
     *
     * @param resizeType
     * @return
     */
    public static String getAliOssImageResizeType(int resizeType) {
        switch (resizeType) {
            case 10:
                return ALI_HANDLE_RESIZE_LFIT.getValue();
            case 11:
                return ALI_HANDLE_RESIZE_MFIT.getValue();
            case 12:
                return ALI_HANDLE_RESIZE_FILL.getValue();
            case 13:
                return ALI_HANDLE_RESIZE_PAD.getValue();
            case 14:
                return ALI_HANDLE_RESIZE_FIXED.getValue();

            default:
                return "";
        }

    }
}
